public class Test2 {
    public static void main(String[] args) {

    }
    public String formatString (String str, char[] arg) {
        // write code here
          String tmp = str.replaceAll("%s" , " ");
          StringBuilder strbu = new StringBuilder();
          int i = 0 , j = 0;
        for (; i < tmp.length(); i++) {
            char ret = tmp.charAt(i);
            if(ret == ' '){
                strbu.append(arg[j++]);
            }else {
                strbu.append(ret);
            }
        }
        for (;  j < arg.length; j++) {
            strbu.append(arg[j]);
        }
        
        return strbu.toString() ;
    }
}
